/* 
 * File:   ConsoleManager.h
 * Author: jorge
 *
 * Created on May 15, 2013, 3:31 PM
 */

#ifndef CONSOLEMANAGER_H
#define	CONSOLEMANAGER_H

#include "ZipValidator.h"
#include <vector>

#define NOT_ARG_MS "The given command is not right\n"
#define COMPRESS_MS "Compress files:\n -c fileName output inputs\n\t-c myzip.zip /myfolder /app.pdf /java.doc\n\n"
#define DECOMPRESS_MS "Decompress a zip file:\n -d output input\n\t-d /myfolder /myzip.zip\n\n"
#define LIST_MS "Show the zip file structure:\n -l input\n\t-l /myzip.zip\n\n"
#define HELP_MS "List command\nYou can write a relative or full path\n\n";

struct Reply
{

    Reply()
    {
        code_ = 0;
    }

    Reply(const char* message, int code = 0) : message_(message), code_(code) { }

    void operator+=(const Reply other)
    {
        this->message_ += other.message_;
    }

    std::string message_;
    int code_;
};

class ConsoleManager
{
public:
    /**
     * @brief Execute a command line according to main arguments
     * 
     * @param argc arguments size
     * @param argv arguments values
     */
    static const Reply executeCommand(int argc, char** argv);
private:
    static const Reply printHelpMessage();
    static const Reply navigate(const char* path);
    static const Reply compress(const char* fileName, const char* output, std::vector<std::string> pathList);
    static const Reply decompress(const char* output, const char* input);
    static void checkArgument(int argc, char command);
    static std::vector<std::string> getPathList(int begin, int end, char** argv);
};

#endif	/* CONSOLEMANAGER_H */

